package cn.xy.ymcc.util;

import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

/**
 * 发送邮件工具类
 */
public class EMailUtils {

    public static void sendMail(String fromEmail, String toEmail, String title, String text){
        SimpleMailMessage mailMessage = new SimpleMailMessage();
        //设置发送人
        mailMessage.setFrom(fromEmail);
        //收件人
        mailMessage.setTo(toEmail);
        //邮件主题
        mailMessage.setSubject(title);
        //邮件内容
        mailMessage.setText(text);

        JavaMailSender bean = (JavaMailSender) cn.xy.ymcc.util.ApplicationContextUtils.getBean("mailSender");
        bean.send(mailMessage);
    }
}